/*
 * @Author: 噜噜雯雯 2199987619@qq.com
 * @Date: 2025-05-27 08:43:07
 * @LastEditors: 噜噜雯雯 2199987619@qq.com
 * @LastEditTime: 2025-09-28 09:59:53
 * @FilePath: \linePatrol\vue-element-plus-admin\src\api\menu\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import service from '@/axios/http'
import { ListIResponse } from '@/utils/Api'
import { MenuListType } from './type'
export class MenuApi {
  //获取菜单树形结构
  async GetDeptListTree(): Promise<ListIResponse<any>> {
    const result = (await service.get(`/api/system/menu/treeselect`)) as unknown as any
    return result
  }
  //查询菜单列表
  async GetMenuList(params: any): Promise<ListIResponse<any[]>> {
    const result = (await service.get(`/api/system/menu/listTre`, { params })) as unknown as any
    return result
  }
  //删除菜单
  async DeletMenu(menuId: number): Promise<boolean> {
    const result = (await service.delete(`/api/system/menu/${menuId}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      // ElMessage.error(msg);
      return false
    }
  }
  //新增岗位
  async AddMenu(data: MenuListType): Promise<boolean> {
    const result = (await service.post('/api/system/menu', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      // ElMessage.error(msg);
      return false
    }
  }
  //修改岗位
  async EditMenu(data: MenuListType): Promise<boolean> {
    const result = (await service.put('/api/system/menu', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      // ElMessage.error(msg);
      return false
    }
  }
}
export default new MenuApi()
